package com.one.web.manage;

import com.one.entity.Application;
import com.one.entity.User;
import com.one.service.ApplicationService;
import com.one.service.UserService;
import com.one.web.BaseServlet;

import javax.servlet.annotation.WebServlet;
import java.util.List;

/**
 * 管理员页面交互类
 * developer 扶立伟
 */
@WebServlet("/manage/menu")
public class ManagerMenu  {

    private static void applyList() {
        List<Application> applies = new ApplicationService().selApplies();
        System.out.println("编号\t姓名\t申请状态\t申请日期");
        for (Application apply: applies) {
            System.out.println(apply.getApply_id() + "\tuj\t"
                    + new UserService().selUser(apply.getUser_id()).getUser_name()
                    + "\t" + (apply.getApply_status()==1?"未审核":
                    (apply.getApply_status()==2?"已通过":"被拒绝")) + "\t"
                    + apply.getApply_date() + "\t" + "申请原因:" + apply.getApply_information());
        }
    }

    private static void userList() {
        List<User> users = new UserService().selUsers();
        System.out.println("用户账号\t\t密码\t姓名\t性别\t用户类型");
        for (User user: users) {
            System.out.println(user.getUser_admin()+"\t\t"+user.getUser_password() +"\t"
            + user.getUser_name() + "\t" + user.getUser_sex() + "\t" +
                    (user.getUser_type()==1?"管理员":"普通用户"));
        }
    }
}
